<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>疫苗预约接种系统</title>
    <link rel="stylesheet" href="./static/css/bootstrap.min.css">
</head>
<body>
    <div class="container col-6">
        <br>
        <a href="addBooking.jsp" class="btn btn-primary">添加预约</a>
        <hr>
        <table class="table table-bordered table-hover table-striped">
            <caption>疫苗预约接种系统</caption>
            <thead>
            <tr>
                <th>预约人姓名</th>
                <th>预约人身份证号</th>
                <th>接种状态</th>
                <th>预约接种日期</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${sessionScope.list}" var="item">
                <tr>
                    <td>${item.userName}</td>
                    <td>${item.cardId}</td>

                    <c:if test="${item.status == 0}">
                        <td>预约</td>
                    </c:if>

                    <c:if test="${item.status == 1}">
                        <td>以接种</td>
                    </c:if>

                    <td>${item.bookDate}</td>
                    <td>
                        <c:if test="${item.status == 0}">
                            <a class="end" name="${item.userName}" id="${item.id}" href="javascript:void(0);">完成接种</a>
                        </c:if>

                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>

        <span style="color: goldenrod">
            ${sessionScope.msg}
        </span>
    </div>

<script src="./static/js/jquery-3.5.1.js"></script>
<script src="./static/js/bootstrap.js"></script>
<script !src="">
    $("body").on("click", ".end", function(){
        if (confirm("确认完成接种吗?")){
            window.location.href = "booking?opr=edit&id=" + $(this).attr("id") + "&name=" + $(this).attr("name");
        }
    })

</script>
</body>
</html>
